package br.com.news.service;

import java.util.List;

import javax.inject.Inject;
import javax.inject.Named;

import br.com.news.utils.business.exception.BusinessException;
import br.com.news.utils.business.interfaces.IAcessoNoticiaBusiness;
import br.com.news.utils.database.beans.AcessoNoticiaBean;
import br.com.news.utils.service.exception.ServiceException;
import br.com.news.utils.service.interfaces.IAcessoNoticiaService;

@Named
public class AcessoNoticiaService implements IAcessoNoticiaService{

	@Inject
	private IAcessoNoticiaBusiness acessoNoticiaBusiness;
	
	@Override
	public List<AcessoNoticiaBean> findAll() throws ServiceException {
		try {
			return acessoNoticiaBusiness.findAll();
		} catch (BusinessException e) {
			throw new ServiceException(e);
		}
	}
	
	@Override
	public List<AcessoNoticiaBean> maisLidasDaSemana(int qntNoticias,int idCategoria) {
		return acessoNoticiaBusiness.maisLidasDaSemana(qntNoticias, idCategoria);
	}
	
	@Override
	public void save(AcessoNoticiaBean acessoNoticiaBean) throws ServiceException {
		try {
			acessoNoticiaBusiness.save(acessoNoticiaBean);
		} catch (BusinessException e) {
			throw new ServiceException(e);
		}
	}

}
